﻿using System;
using System.Runtime.CompilerServices;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Common;
using Ths.Components.Common;
using Ths.Framework;
using Ths.Components.Dictionary;
using Ths.Components.Dictionary.Entity;
using Ths.Components.Excel;
using Ths.Components;
using Dundas.Charting.WebControl;
public partial class DistressManage_AnalysisNotType : Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            List<DbParameter> parameterList = new List<DbParameter>();

            DbParameter theSqlParameter = null;
            DataAccess da = new DataAccess();
            DBBase dbBase = new DBBase();
            string where = " ";
            if (GetRequestStr("starttime") != string.Empty)
            {
                where += "  AND HappenTime >= @HappenTime";
                theSqlParameter = dbBase.DBFactory.CreateParameter("@HappenTime", Convert.ToString(GetRequestStr("starttime") + " 00:00:00"));
                parameterList.Add(theSqlParameter);
                this.txtStartTime.Value = GetRequestStr("starttime");
            }

            if (GetRequestStr("endtime") != string.Empty)
            {
                where += "  AND HappenTime <= @HappenTime2";
                theSqlParameter = dbBase.DBFactory.CreateParameter("@HappenTime2", Convert.ToString(GetRequestStr("endtime") + " 23:59:59"));
                parameterList.Add(theSqlParameter);
                this.txtEndTime.Value = GetRequestStr("endtime");
            }

            string strWhere = "";
            if (Session["ResponseRemark"].ToString() != "局级")
            {
                strWhere += " and companyid in (" + Session["bmqxa"].ToString().Trim() + ") ";
            }
            DataTable dtMonthLicence = da.GetDataTable("select b.name,COUNT(1) as heji from dbo.NotHurtDistress a,qp_hr_SysData  b where a.Type=b.id and b.type='15' and isnull(a.status,'0')='55' " + where + " " + strWhere + " group by b.name", CommandType.Text, parameterList.ToArray());
            //string monthLicenceTitle = dtMonthLicence.Rows[2]["name"].ToString();

            switch (GetRequestStr("type"))
            {
                case "0":
                    UCChart1.ChartType = SeriesChartType.Pie;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                case "1":
                    UCChart1.ChartType = SeriesChartType.Column;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                case "2":
                    UCChart1.ChartType = SeriesChartType.Line;
                    this.drpType.SelectedValue = GetRequestStr("type");
                    break;
                default:
                    UCChart1.ChartType = SeriesChartType.Pie;
                    break;
            }


            //dtMonthLicence.Rows.RemoveAt(2);
            UCChart1.DtSource = dtMonthLicence;
            UCChart1.ImageName = "02-02";
            UCChart1.Width = 400;
            UCChart1.Height = 300;

        }
    }


    protected void btnSave_Click(object sender, EventArgs e)
    {
        Response.Redirect("AnalysisNotType.aspx?starttime=" + this.txtStartTime.Value + "&type=" + this.drpType.SelectedValue + "&endtime=" + this.txtEndTime.Value);
    }
    protected void drpType_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect("AnalysisNotType.aspx?starttime=" + this.txtStartTime.Value + "&type=" + this.drpType.SelectedValue + "&endtime=" + this.txtEndTime.Value);
    }
}
